rm(list= ls())

##

library(tidyverse)
library(readxl)

## Load data and clean up 

fg <- read_excel('data/FGW_Salience.xlsx', skip = 6, 
                 col_types = c('date', rep('text', 6))) %>% 
  dplyr::rename(date = 1) %>% 
  mutate(y = lubridate::year(date)) %>% 
  filter(y > 2015) %>% 
  dplyr::rename(Education = 2,
                `Pensions` = 3,
                `Immigration /\nrefugees` = 4,
                `Climate change /\nenvironment` = 5,
                `Social inequality` = 6,
                `Covid-19` = 7) %>% 
  dplyr::select(-y) %>% 
  pivot_longer(-date) %>% 
  mutate(value = as.numeric(value)) %>% 
  mutate(date = as.Date(date)) %>% 
  filter(name %in% c('Covid-19', 'Climate change /\nenvironment', 'Immigration /\nrefugees'))

#### Figure A.3 - issue salience ####

fg %>% 
  ggplot(aes(date, value)) +
  geom_vline(xintercept = as.Date('2021-07-15'), linetype = 'dotted') +
  geom_vline(xintercept = as.Date('2017-09-24'), linetype = 'dashed') +
  geom_vline(xintercept = as.Date('2021-09-24'), linetype = 'dashed') +
  geom_smooth(span = 0.45, method = "loess", se = F, aes(color = name)) +
  theme_bw() +
  theme(axis.title.x = element_blank()) +
  ylab('Salience') +
  scale_color_brewer(type = 'qual',
                     name = '') +
  theme(legend.position = 'bottom')